package problem.nc141;

// https://www.nowcoder.com/practice/e297fdd8e9f543059b0b5f05f3a7f3b2

public class Solution {
    public boolean judge (String str) {
        // 获取字符串的长度
        int len = str.length();
        // 仅需要循环一半即可，偶数个刚好判断完，奇数个恰好不用判断最中间的值
        for (int i = 0; i < len / 2; i++) {
            // 如果不相等就直接返回，相等则继续判断
            if (str.charAt(i) != str.charAt(len - 1 - i)) {
                return false;
            }
        }
        return true;
    }
}
